import json
# with open("test.json","r",encoding="utf8") as f:
#     dict1=json.load(f)
#     dict1['age']=30
#
# with open("test.json","w",encoding="utf8") as f:
#     json.dump(dict1,f,ensure_ascii=False)
with open("test.json","r+",encoding="utf8")as f:
    dict1 = json.load(f)
    dict1['age']=30
    f.seek(0)  # 把写入的指针放到文件的最前面
    json.dump(dict1,f,ensure_ascii=False)














